package calorie.com.calorie.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;

import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.constant.Constant;
import calorie.com.calorie.request.GoodsListRequest;
import calorie.com.calorie.response.GoodsListResponce;
import retrofit2.Call;
import retrofit2.Response;

/**
 * Created by chenxi on 2019/4/10.
 */

public class GoodsListContact {
    public static class GoodsListPresent extends BasePresent<IGoodsListView>{
        public void goodsList(final Context context,Integer pageNo){
            ApiService service = ServiceGenerator.createService(ApiService.class);
            GoodsListRequest request = new GoodsListRequest(pageNo);
            service.getGoodsList(request).enqueue(new NetCallBack<GoodsListResponce>() {
                @Override
                public void onSuccess(Call<GoodsListResponce> call, Response<GoodsListResponce> response) {
                    if(getView()!= null){
                        getView().getGoodsListResult(response);
                    }
                }

                @Override
                public void onFailed() {

                }
            });
        }
    }

    public interface IGoodsListView extends IBaseView{
        void getGoodsListResult(Response<GoodsListResponce> response);
    }
}
